<?php
/*
 *author:Yangligao
 *Date:2013-9-24
 */
require '../../Config.php';
$flag = $_GET['flag'];
	$adminModel = new AdminModel();
if($flag == 'display'){
 	$res = $adminModel->admin_select('admin_power','where admin_id='.$_SESSION['id']);		
	$smarty->assign('power',$res[0]['admin_power'][0]);
	$smarty->display("Admin/addadmin.html");
}else{
	$arr['admin_power'] = '';
	$arr['admin_name'] = $_POST['admin_name'];
	$arr['admin_pwd'] = base64_encode($_POST['newPwd']);  //reNewPwd
	$arr['admin_power'] .= isset($_POST['insert'])?$_POST['insert']:'0';
	$arr['admin_power'] .= isset($_POST['delete'])?$_POST['delete']:'0';
	$arr['admin_power'] .= isset($_POST['update'])?$_POST['update']:'0';
	if( $_POST['newPwd'] == $_POST['reNewPwd']){
		
		$res = $adminModel->admin_insert($arr);
		if($res){
			jump("管理员添加成功！", $_SERVER['HTTP_REFERER']);
		}else{
			alertInfo("管理员添加失败，请核对...", $_SERVER['HTTP_REFERER']);
		}
	}else{
		alertInfo("两次密码不一致，请仔细核对...", $_SERVER['HTTP_REFERER']);
	}
}
?>
